/*
 * Tank.java
 *
 * Created on 2 2007 0:15
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package com.persistent.entity;

import java.io.Serializable;
import java.math.BigInteger;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 * Entity class Tank
 * 
 * @author alexog
 */
@Entity
@Table(name = "tank")
@NamedQueries( {
        @NamedQuery(name = "Tank.findById", query = "SELECT t FROM Tank t WHERE t.id = :id")
    })
public class Tank implements Serializable {

    @Id
    @Column(name = "ID", nullable = false)
    private BigInteger id;

    @JoinColumn(name = "ACCOUNT", referencedColumnName = "ID")
    @ManyToOne
    private Account account;
    
    /** Creates a new instance of Tank */
    public Tank() {
    }

    /**
     * Creates a new instance of Tank with the specified values.
     * @param id the id of the Tank
     */
    public Tank(BigInteger id) {
        this.id = id;
    }

    /**
     * Gets the id of this Tank.
     * @return the id
     */
    public BigInteger getId() {
        return this.id;
    }

    /**
     * Sets the id of this Tank to the specified value.
     * @param id the new id
     */
    public void setId(BigInteger id) {
        this.id = id;
    }

    /**
     * Gets the accountidId of this Tank.
     * @return the accountidId
     */
    public Account getAccount() {
        return this.account;
    }

    /**
     * Sets the accountidId of this Tank to the specified value.
     * @param accountidId the new accountidId
     */
    public void setAccount(Account account) {
        this.account = account;
    }

    /**
     * Returns a hash code value for the object.  This implementation computes 
     * a hash code value based on the id fields in this object.
     * @return a hash code value for this object.
     */
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (this.id != null ? this.id.hashCode() : 0);
        return hash;
    }

    /**
     * Determines whether another object is equal to this Tank.  The result is 
     * <code>true</code> if and only if the argument is not null and is a Tank object that 
     * has the same id field values as this object.
     * @param object the reference object with which to compare
     * @return <code>true</code> if this object is the same as the argument;
     * <code>false</code> otherwise.
     */
    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Tank)) {
            return false;
        }
        Tank other = (Tank)object;
        if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) return false;
        return true;
    }

    /**
     * Returns a string representation of the object.  This implementation constructs 
     * that representation based on the id fields.
     * @return a string representation of the object.
     */
    @Override
    public String toString() {
        return "com.persistent.entity.Tank[id=" + id + "]";
    }
    
}
